curl http

您所在的位置:网站首页 http code 实战 curl http

curl http

2023-09-13 17:36| 来源: 网络整理| 查看: 265

1.只得到一个url的http_code的状态码

 curl -I -m 10 -o /dev/null -s -w %{http_code} http://127.0.0.1/a.html

 

 

查询head

curl --head http://192.168.56.11:32769/

HTTP/1.1 200 OK Server: nginx/1.11.3 Date: Fri, 02 Sep 2016 17:44:14 GMT Content-Type: text/html Content-Length: 612 Last-Modified: Tue, 26 Jul 2016 14:54:48 GMT Connection: keep-alive ETag: "579779b8-264" Accept-Ranges: bytes

2.curl命令参数详解:  由于linux curl功能十分强大,所以命令参数十分多,下表只是爱E族(aiezu.com)帅选出来的部分参数,更多参数请运行“man curl”命令查看。

参数组参数描述 url url 需要抓取的一到多个URLs;多个下面通配符的方式:  1、http://{www,ftp,mail}.aiezu.com;  2、http://aiezu.com/images/[001-999].jpg;  3、http://aiezu.com/images/[1-999].html;  4、ftp://aiezu.com/file[a-z].txt 请求头 -H "name: value"--header "name: value" (HTTP)添加一个http header(http请求头); -H "name:"--header "name:" (HTTP)移除一个http header(http请求头); -A "string"--user-agent "string"【参考】 (HTTP)设置Http请求头“User-Agent”,服务器通过“User-Agent”可以判断客户端使用的浏览器名称和操作系统类型,伪造此参数能导致服务器做出错误判断。也可以使用“-H”, “--header option”设置此选项; -e --referer 【参考】 (HTTP)设置访问时的来源页面,告诉http服务从哪个页面进入到此页面;-e "aiezu.com"相当于“-H "Referer: www.qq.com"”; 响应头 -I--head (HTTP)只输出HTTP-header,不获取内容(HTTP/FTP/FILE)。用于HTTP服务时,获取页面的http头;  (如:curl -I http://aiezu.com)用于FTP/FILE时,将会获取文件大小、最后修改时间;  (如:curl -I file://test.txt) -i--include (HTTP)输出HTTP头和返回内容; -D --dump-header (HTTP)转储http响应头到指定文件; cookie -b name=data--cookie name=data【参考】 (HTTP)发送cookie数据到HTTP服务器,数据格式为:"NAME1=VALUE1; NAME2=VALUE2";

如果行中没有“=”,将把参数值当作cookie文件名;

这个cookie数据可以是由服务器的http响应头“Set-Cookie:”行发送过来的;

-c filename--cookie-jar file name【参考】 (HTTP)完成操作后将服务器返回的cookies保存到指定的文件;指定参数值为“-”将定向到标准输出“如控制台”; -j--junk-session-cookies (HTTP)告诉curl放弃所有的"session cookies";相当于重启浏览器; 代理 -x host:port-x [protocol://[user:pwd@]host[:port]--proxy [protocol://[user:pwd@]host[:port]【参考】 使用HTTP代理访问;如果未指定端口,默认使用8080端口;protocol默认为http_proxy,其他可能的值包括:http_proxy、HTTPS_PROXY、socks4、socks4a、socks5;如:--proxy 8.8.8.8:8080;-x "http_proxy://aiezu:[email protected]:80" -p--proxytunnel 将“-x”参数的代理,作为通道的方式去代理非HTTP协议,如ftp; --socks4 --socks4a --socks5 【参考】 使用SOCKS4代理;使用SOCKS4A代理;使用SOCKS5代理;此参数会覆盖“-x”参数; --proxy-anyauth--proxy-basic--proxy-diges--proxy-negotiate--proxy-ntlm http代理认证方式,参考:--anyauth--basic--diges--negotiate--ntlm -U --proxy-user 设置代理的用户名和密码; 数据传输 -G--get【参考】 如果使用了此参数,“-d/”、“--data”、“--data-binary”参数设置的数据,讲附加在url上,以GET的方式请求;  -d @file-d "string"--data "string"--data-ascii "string"--data-binary "string"--data-urlencode "string"【参考】 (HTTP)使用HTTP POST方式发送“key/value对”数据,相当于浏览器表单属性(method="POST",enctype="application/x-www-form-urlencoded")  -d,--data:HTTP方式POST数据;  --data-ascii:HTTP方式POST ascii数据;  --data-binary:HTTP方式POST二进制数据;  --data-urlencode:HTTP方式POST数据(进行urlencode);如果数据以“@”开头,后紧跟一个文件,将post文件内的内容; -F name=@file-F name=


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3